#include "head.h"

void Move_character(const int num) {
  if (num == 0) {
#ifdef __WIN32__
    system("taskkill /f /t /im wmplayer.exe"); //�
#endif
    exit(0);
  } else if (num == 8 || num == 6 || num == 2 || num == 4)
    judge(movexx[num], moveyy[num]);
  else {
    puts("Wrong number,enter again");
    needcls = 0;
  }
}
void move_character() {
  int num = getch() - '0';
  if (num == 5) {
    if (bfs(nowx, nowy, 1)) {
      display_card();
      printf("if you can see this message,something is wrong");
      int find_x = queuex[tail];
      int find_y = queuey[tail];
      p = 0;
      do {
        path[++p] = record[find_x][find_y];
        find_x -= movexx[path[p]];
        find_y -= moveyy[path[p]];
      } while (record[find_x][find_y]);
    } else {
      puts("Error");
      needcls = 0;
    }
  } else
    Move_character(num);
}
void enter_the_game() {
  printf("press the 'enter' to enter the game\n");
  if (getch()) {
    printf("welcome to the game world\n");
    mySleep(500);
    system("clear");
    project();
  }
}
int main() {
  system("music.wav"); //�
#ifdef __WIN32__
  HideCursor();
#endif
begain:
  system("clear");
  system("color 3f");
  printf("---------------------------------------------------------------------"
         "--------------------------------------------------\n");
  printf("*********************************************************************"
         "**************************************************\n\n");
  printf("                                                       GAME\n");
  printf("                                        "
         "=====================================\n");
  printf("                                        Reminder:  Do not indulge in "
         "the game\n");
  printf("                                        "
         "=====================================\n");
  printf("                              * * *     * * * * *        *          "
         "* * * *      * * * * *\n");
  printf("                            *               *           * *         "
         "*       *        * \n");
  printf("                            *               *          *   *        "
         "*       *        *\n");
  printf("                              * * *         *         *     *       "
         "* * * *          *\n");
  printf("                                    *       *        * * * * *      "
         "* *              *\n");
  printf("                                    *       *       *         *     "
         "*   *            *\n");
  printf("                            * * * *         *      *           *    "
         "*     * *        *\n\n\n");
  printf("                                                      Enter: w\n");
  printf("                                                      Rank: r\n");
  printf("                                                      Rule: f\n");
  printf("                                                      About us: n\n");
  printf("                                                      Leave: 0\n\n");
  printf("                         Adapt to people older than 8 yeard old "
         ",Refused to piracy Resist bad games\n");

  switch (getch()) {
  case 'w':
    project();
    break;
  case 'f':
    system("clear");
    printf("                                            rule of the game\n");
    printf("         You control a character  on a map. Get  the   maximum of "
           "gold coins.   But watch out for monsters and traps. \n");
    printf("A gold coin counter  (initially at 0)  will  be  incremented  each "
           "time  the character  passes  over a  box  containing \n");
    printf("a gold coin. A life counter (initially at 10) is decremented each "
           "time the character passes on a trap box. Once the gold \n");
    printf("coin is taken or the trap is activated, the object disappears from "
           "the card \n");
    printf("if you recovered 10 gold coins. In this case, hyou won \n");
    printf("if you has passed to 0 life points. In this case, you has lost\n ");
    printf("good luck !\n\n\n\n");
    enter_the_game();
    break;
  case 'n':
    system("clear");
    printf("    the game directed by Mr.Member1  Mr.Member2 and Mr.Member3\n");
    printf("this game is just a project of our homework while We will \n");
    printf(" pursue legal and moral responsibility if infringement occurs\n");
    printf("Thank you for your cooperation!\n");
    enter_the_game();
    break;
  case '0':
    break;
  case 'r':
    show_rank();
    break;
  default:
    printf("error\n");
    mySleep(500);
    goto begain;
  }
#ifdef __WIN32__
  system("pause");
  system("taskkill /f /t /im wmplayer.exe"); //�
#endif
}
